package com.zzuli.yxypre.controller;

import com.zzuli.yxypre.comment.R;
import com.zzuli.yxypre.service.SingerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @auther pony
 * @create 2023-05-06 16:15
 */
@RestController
@RequestMapping("singer")
@CrossOrigin(origins = "*")
public class SingerController {
    @Autowired
    private SingerService singerService;

    /**
     * 查询歌手分页信息
     * @param nav all:全部 A-Z:歌手首字母 #:其他
     * @param pageCurrent 当前页
     * @param pageSize 每页条数
     * @return
     */
    @GetMapping("/page/{nav}/{pageCurrent}/{pageSize}")
    public R page(@PathVariable("nav") String nav, @PathVariable("pageCurrent") Integer pageCurrent,
                         @PathVariable("pageSize") Integer pageSize){
        return singerService.page(nav, pageCurrent, pageSize);
    }

    /**
     * 根据 歌手 id 获取歌手信息
     * @param id
     * @return
     */
    @GetMapping("getOneById/{id}")
    public R getOneById(@PathVariable("id") Integer id, HttpServletRequest request){
        return singerService.getOneById(id, request);
    }

}
